package com.nageoffer.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nageoffer.shortlink.project.common.refactor.LinkAccessLogsMapperRefactor;
import com.nageoffer.shortlink.project.common.refactor.LinkGroupAccessLogsMapperRefactor;
import com.nageoffer.shortlink.project.dao.entity.LinkAccessLogsDO;
import com.nageoffer.shortlink.project.dao.entity.LinkAccessStatsDO;
import com.nageoffer.shortlink.project.dto.req.ShortLinkGroupStatsAccessRecordReqDTO;
import com.nageoffer.shortlink.project.dto.req.ShortLinkGroupStatsReqDTO;
import com.nageoffer.shortlink.project.dto.req.ShortLinkStatsReqDTO;
import org.apache.ibatis.annotations.Param;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 访问日志监控持久层
 */
public interface LinkAccessLogsMapper extends BaseMapper<LinkAccessLogsDO> {
    /**
     * 根据短链接获取指定日期高频IP
     */
    List<HashMap<String, Object>> listTopIpByShortLink(@Param("requestParam") ShortLinkStatsReqDTO requestParam);

    /**
     * 根据分组获取从高频访问IP详情
     */
    List<HashMap<String, Object>> listTopIpByGroup(@Param("requestParam") ShortLinkGroupStatsReqDTO requestParam);

    /**
     * 根据短链接获取指定日期新老用户访问量
     */
    HashMap<String, Object> findUvTypeCntByShortLink(@Param("requestParam") ShortLinkStatsReqDTO requestParam);

    /**
     * 根据用户信息访问新老访客
     */
    List<Map<String, Object>> selectUvTypeByUsers(@Param("requestParam") LinkAccessLogsMapperRefactor requestParam);

    /**
     * 根据分组信息访问新老访客
     */
    List<Map<String, Object>> selectGroupUvTypeByUsers(@Param("requestParam") LinkGroupAccessLogsMapperRefactor linkAccessLogsMapperRefactor);

    /**
     * 根据短链接获取指定日期pv,uv,uip
     */
    LinkAccessStatsDO findPvUvUipStatsByShortLink(@Param("requestParam") ShortLinkStatsReqDTO requestParam);

    /**
     * 根据短链接获取从高频访问IP详情
     */
    LinkAccessStatsDO findPvUvUipStatsByGroup(@Param("requestParam") ShortLinkGroupStatsReqDTO requestParam);

    IPage<LinkAccessLogsDO> selectGroupPage(@Param("requestParam") ShortLinkGroupStatsAccessRecordReqDTO requestParam);
}
